package com.example.springboottest.example;

import java.util.*;

public class GZ {

    public static void main(String[] args) {
        Map<String, Double> totals = new TreeMap<>();
        java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
        totals.put("2016", 3.6);
        totals.put("2017", Double.valueOf(df.format(0.6 + 12 * 1.82)));
        totals.put("2018", Double.valueOf(df.format(3.6 + 12 * 2.12)));
        totals.put("2019", Double.valueOf(df.format(4.2 + 12 * 2.22)));
        totals.put("2020", Double.valueOf(df.format(2.2 + 3.0 + 12 * 2.4)));
        totals.put("2021", Double.valueOf(df.format(2.4 + 3.0 + 12 * 2.57)));
//        totals.put("2022", Double.valueOf(df.format(2.55 + 3.0 + 12 * 2.7)));

        totals.forEach((key, value) -> {
            System.out.println(key + " : " + value);
        });

        Double totalMoney = totals.values().stream().reduce(0.0, Double::sum);

        System.out.println("总数：" + df.format(totalMoney));

    }

}
